<%-- 
    Document   : ProsesPendftaran
    Created on : Nov 20, 2012, 7:23:07 PM
    Author     : Yo
--%>

<%@page import="java.sql.ResultSet"%>
<%@page import="bean.ProsesBean"%>
<%@page import="Data.CalonSiswa"%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>

        <title>Verifikasi</title>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title></title>
        <meta name="keywords" content="" />
        <meta name="description" content="" />
        <link href="http://fonts.googleapis.com/css?family=Open+Sans+Condensed:300" rel="stylesheet" type="text/css" />
        <link href="default.css" rel="stylesheet" type="text/css" media="all" />
    </head>
    <body style="margin: 0px;">

        <%


            CalonSiswa cln = new CalonSiswa();
            ProsesBean bn = new ProsesBean();
            //ResultSet no = bn.cariNoPendafMAX();

            //while (no.next()) {
              //  int np = no.getInt(1);
                //System.out.println(np);

                //ResultSet npendf = bn.noPendf(np);
                //int jmlh = 0;
                //while (npendf.next()) {
                  //  System.out.println(npendf.getInt(1));
                    //jmlh++;

                    //int i = 1;
                    //if (jmlh == 1) {

                      //  int noPdftrn = npendf.getInt(1) + i;
                        //System.out.println(noPdftrn);
                        //cln.setNoPendaftaran(noPdftrn);

                    //}
                //}
            //}

            //String noPndft = request.getParameter("noPdftrn");
            //System.out.println(noPndft);

            String nama = request.getParameter("nama");
            //String tgl_lhir = request.getParameter("tgl_lahir");
            String noujian = request.getParameter("Noujian");
            int b = Integer.parseInt(noujian);

            //String sekolah = request.getParameter("asalsekolah");
            //String nilai = request.getParameter("nilai");
            //int c = Integer.parseInt(nilai);

            //String p1 = request.getParameter("pilihan1");
            //String p2 = request.getParameter("pilihan2");

            ProsesBean cn = new ProsesBean();
            ResultSet rest = cn.cekNoUjian(b);
            int jml = 0;
            while (rest.next()) {
               jml++;
            }

            if ((nama.matches("[A-Za-z]*")) && jml != 1) {
                
                ResultSet no = bn.cariNoPendafMAX();
                while (no.next()) {
                    int np = no.getInt(1);
                    System.out.println(np);

                    ResultSet npendf = bn.noPendf(np);
                    int jmlh = 0;
                    while (npendf.next()) {
                        System.out.println(npendf.getInt(1));
                        jmlh++;

                        int i = 1;
                        if (jmlh == 1) {

                            int noPdftrn = npendf.getInt(1) + i;
                            System.out.println(noPdftrn);
                            cln.setNoPendaftaran(noPdftrn);

                        }
                    }
                }

                String noPndft = request.getParameter("noPdftrn");
                System.out.println(noPndft);
                String tgl_lhir = request.getParameter("tgl_lahir");
                String sekolah = request.getParameter("asalsekolah");
                String nilai = request.getParameter("nilai");
                int c = Integer.parseInt(nilai);

                String p1 = request.getParameter("pilihan1");
                String p2 = request.getParameter("pilihan2");

                

                cln.setNama(nama);
                cln.setTanggal_lahir(tgl_lhir);
                cln.setNoUjian(b);
                cln.setAsalSekolah(sekolah);
                cln.setNilai(c);
                cln.setPilihan_1(p1);
                cln.setPilihan_2(p2);
                cn.Pendaftaran(cln);

            } else if (nama.length() > 30) {
                response.sendRedirect("error.jsp");
            } else if (jml == 1) {
                response.sendRedirect("error3.jsp");
            } else {
                response.sendRedirect("error4.jsp");
            }

            ResultSet temp = bn.noPendfVerifi(b);
            temp.next();
        %>

        <div id="header" class="container">
            <div id="logo">
                <h1><a href="#">Pendafataran SMA Negeri Online</a></h1>
                <p>Yogyakarta</a></p>
            </div>
        </div>
        <div id="menu" class="container">
            <ul>
                <li><a href="FormUtama.jsp" accesskey="1" title="">Home</a></li>
                <li><a href="FormPendaftaran.jsp" accesskey="1" title="">Pendafataran</a></li>
                <li><a href="FormPengumuman.jsp" accesskey="2" title="">Pengumuman</a></li>
                <li ><a href="FormInformasi.jsp" accesskey="3" title="">Informasi</a></li>
                <li><a href="#" accesskey="4" title=""></a></li>
                <li><a href="#" accesskey="5" title=""></a></li>
            </ul>
        </div>
        <div id="page" class="container">


            <div id="content">
                <br> <br> <br> <br> <br>
                <table width="85%"border="0" align ="center">
                    <tr>
                        <td><h3>Verifikasi Pendaftaran</h3></td>
                    </tr>
                    <tr>
                        <td width="30%"><code><p>No Pendaftaran </p></code></td>
                        <td width="20%"><code><p>: <%=temp.getInt(1)%></p></code></td>
                    </tr>
                    <tr>
                    </tr>
                    <tr >
                        <td><code><p>Nama lengkap</p></code></td>
                        <td><code><p>: <%= request.getParameter("nama")%></p></code></td>
                    </tr>
                    <tr >
                        <td><code><p>Tanggal Lahir </p></code></td>
                        <td><code><p>: <%= request.getParameter("tgl_lahir")%></p></code></td>
                    </tr>
                    <tr >
                        <td><code><p>No Ujian</p></code></td>
                        <td><code><p>: <%= request.getParameter("Noujian")%></p></code></td>
                    </tr>
                    <tr >

                        <td><code><p>Asal Sekolah</p></code></td>
                        <td><code><p>: <%= request.getParameter("asalsekolah")%></p></code></td>
                    </tr>
                    <tr >
                        <td><code><p>Nilai total</p></code></td>
                        <td><code><p>: <%= request.getParameter("nilai")%></p></code></td>
                    </tr>
                    <tr align="">
                        <td><code><p>Pilihan 1</p></code></td>
                        <td><code><p>: <%= request.getParameter("pilihan1")%></p></code></td>
                    </tr>
                    <tr >
                        <td><code><p>Pilihan 2</p></code></td>
                        <td><code><p>: <%= request.getParameter("pilihan2")%></p></code></td>
                    </tr>

                </table>
                <br><br>

            </div>

        </div>
        <div id="footer">
            <p>Copyright (c) 2012 www.Vido_Dido.com </p>
        </div>
    </body>
</html>

